package com.qianfeng.openapi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qianfeng.openapi.mapper.ApiSystemparamMapper;
import com.qianfeng.openapi.pojo.ApiSystemparam;
import com.qianfeng.openapi.service.ApiSystemparamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

@Service
@Transactional
public class ApiSystemparamServiceImpl implements ApiSystemparamService {
    @Autowired
    private ApiSystemparamMapper apiSystemparamMapper;
    @Override
    public void insertApiSystemparam(ApiSystemparam apiSystemparam) {
        apiSystemparamMapper.insert(apiSystemparam);
    }

    @Override
    public void deleteApiSystemparam(Integer[] ids) {
        List<Integer> list = Arrays.asList(ids);
        apiSystemparamMapper.deleteBatchIds(list);
    }

    @Override
    public void updateApiSystemparam(ApiSystemparam apiSystemparam) {
        apiSystemparamMapper.updateById(apiSystemparam);
    }

    @Override
    public ApiSystemparam selectApiSystemparamByName(String name) {
        ApiSystemparam apiSystemparam = apiSystemparamMapper.selectById(name);
        return apiSystemparam;
    }

    @Override
    public PageInfo<ApiSystemparam> getAllApiSystemparam(int page, int limit, ApiSystemparam apiSystemparam) {
        QueryWrapper<ApiSystemparam> queryWrapper=new QueryWrapper<>();
        PageHelper.startPage(page,limit);
        List<ApiSystemparam> apiSystems = apiSystemparamMapper.selectList(queryWrapper);
        PageInfo<ApiSystemparam> pageInfo=new PageInfo<>(apiSystems);
        return pageInfo;
    }
}
